﻿using System.Threading;
using System.Threading.Tasks;

namespace HardStyle.SimpleEventBus
{
    public interface ISimpleEventHandle<in TEvent>
        where TEvent : ISimpleEvent
    {
        Task Handle(TEvent e, CancellationToken cancellationToken);
    }


    public abstract class SimpleEventHandle<TEvent> : ISimpleEventHandle<TEvent>
    where TEvent : ISimpleEvent
    {
        Task ISimpleEventHandle<TEvent>.Handle(TEvent e, CancellationToken cancellationToken)
        {
            Handle(e);
            return Task.CompletedTask;
        }


        protected abstract Task Handle(TEvent e);
    }


}
